#!/bin/bash
#常用命令
cd  /app;
[ -f /app/chfs ]|| {
cat /proc/cpuinfo | grep "model name"| egrep  -i  arm && unzip chfs-linux-arm64*
cat /proc/cpuinfo | grep "model name"| egrep  -i  arm || unzip chfs-linux-amd64*
}
_conf  () {
cat  > /config/chfs.ini  <<  EOF
port=${port}
path=${path}
allow=${allow}
log=${log}
html.title=${html_title}
html.notice=${html_notice}
image.preview=${image_preview}
folder.download=${folder_download}
ssl.cert=${ssl_cert}
ssl.key=${ssl_key}
session.timeout=${session_timeout}
file.remove=${file_remove}

[${user_name}]
password=${user_password}
rule.default=${user_rule_default}
rule.none=${user_rule_none}
rule.r=${user_rule_r}
rule.w=${user_rule_w}
rule.d=${user_rule_d}

[guest]
password=${guest_password}
rule.default=${guest_rule_default}
rule.none=${guest_rule_none}
rule.r=${guest_rule_r}
rule.w=${guest_rule_w}
rule.d=${guest_rule_d}
EOF
}


#
[ ! -f /config/chfs.ini ] && _conf || [ "$use_local_config" = false ] && _conf
#
chfs=$(ls  /app/chfs-linux* |egrep  -v "zip"|head -n 1)
ls -l /app/
chmod +x  ${chfs}
${chfs} --file=/config/chfs.ini

#重启容器生效
# docker  restart  chfs

